package kokonut.shop.cart;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class UpdateCartServlet extends HttpServlet{
	@Override
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {

		int amount = Integer.parseInt(req.getParameter("amount"));
		int productNumber = Integer.parseInt(req.getParameter("productNumber"));
		CartController controller = new CartController();
		SelectedProduct product = controller.getProductByPosition(productNumber);
		//Sets the new amount to the product
		product.setAmount(amount);
		//There is no need to save back the product because its updated with last line
	}

}